//###############
// FILE : LogTab.java
// WRITER : Lior Zimmerman liorz06 066462300
// WRITER : Ohad Dan ohad_dan 036767960
// EXERCISE : oop ex3 2008
// DESCRIPTION:
// Representation of the SetUp tab.
//###############

package oop.ex3.fileSearchView;
import java.awt.FlowLayout;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import oop.ex3.fileSearchController.ClearLogAction;

/**
 * Representation of the SetUp tab.
 */
public class LogTab extends GUITab implements LogTabInterface{
    private static final long serialVersionUID = 1L;

    //********************************************************************
    //  Data members :                                                   *
    //********************************************************************
    private JButton _btnClear;
    private JTextArea _txtLog;
    private JScrollPane _txtLogScroll;
    
    //********************************************************************
    //  Finals :                                                         *
    //********************************************************************
    private final String TAB_TITLE = "Log Dialog";
    private final String STR_CLEAR_BUTTON = "Clear";
    private final int TXT_LOG_WIDTH = 15;
    private final int TXT_LOG_HEIGHT = 20;
    //********************************************************************
    //  Methods :                                                        *
    //********************************************************************  
     /**
     * Construct a new log tab.
     * @param gui The main frame.
     */
    public LogTab( GUIInitializer gui ) {
        super(gui);
        setLayout( new FlowLayout() );
        setBorder( BorderFactory.createTitledBorder(TAB_TITLE) );
        _txtLog = new JTextArea(TXT_LOG_WIDTH,TXT_LOG_HEIGHT);
        _txtLogScroll = new JScrollPane(_txtLog);
        _btnClear = new JButton(STR_CLEAR_BUTTON);
        add(_txtLogScroll);
        add(_btnClear);
    }
    /**
     * Sets all component's action listener.
     */
    public void setActionListeners() {
        _btnClear.addActionListener( new ClearLogAction(_guiPointer));
    }
    /**
     * Returns the log text.
     * @return Log text.
     */
    public String getLogTxt() {
        return _txtLog.getText();
    }
    /**
     * Clears the log text.
     */
    public void clearLogText(){
    	_txtLog.setText("");
    }
    /**
     * Sets text on log text area.
     */
    public void setLogText(String str){
    	_txtLog.setText(_txtLog.getText() + str);
    }
}
